package code;

/**
 * 
 * Contains the credit card information. 
 *
 */
public class CreditCard extends CardTypes
{
	private double fLimit; // you cannot spend more than this limit
	private double fBalance;
	
	/**
	 * Creates credit card. 
	 */
	public CreditCard()
	{
		fCardNumber = fNextCardNumber;
		fNextCardNumber++;
		fLimit = 2500; // standard limit
		fBalance = 0;
	}
	
	/**
	 * Creates credit card with a given limit. 
	 * @param limit the limit on the card. 
	 */
	public CreditCard(double limit)
	{
		fCardNumber = fNextCardNumber;
		fNextCardNumber++;
		fLimit = limit;
		fBalance = 0;
	}
	
	@Override
	public boolean pay(double amount)
	{
		if((fBalance - amount) < -fLimit)
		{
			fBalance -= amount;
			return true;
		}
		else
		{
			return false;
		}
	}
}
